package com.lpw.dbvideo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * 微信配置类
 */
@Configuration
@PropertySource(value = "classpath:application.properties")
public class WeChatConfig {
    /**
     * 微信公众号AppId
     */
    @Value("${wx.oa.appid}")
    private String wxOAAppId;
    /**
     * 微信公众号AppSecret
     */
    @Value("${wx.oa.appsecret}")
    private String wxOAAppSecret;

    /**
     * 微信开放平台 openappid
     */
    @Value("${wx.open.appid}")
    private String wxOpenAppId;

    /**
     * 微信开放平台 openappsecret
     */
    @Value("${wx.open.appsecret}")
    private String wxOpenSecret;

    /**
     * 微信开放平台重定向地址
     */
    @Value("${wx.open.redirecturl}")
    private String wxOpenRedirectUrl;

    /**
     * 微信开放平台二维码地址
     */
//    private static final String OPEN_QRCODE_URL = "https://open.weixin.qq.com/connect/qrconnect?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect";
    private static final String OPEN_QRCODE_URL = "http://127.0.0.1:8081/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=SCOPE&state=%s#wechat_redirect";

    /**
     * 开放平台获取access_token 地址
     */
//    private static final String OPEN_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
    private static final String OPEN_ACCESS_TOKEN_URL = "http://127.0.0.1:8081/connect/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";

    /**
     * 获取微信用户信息的接口
     */
//    private static final String OPEN_USER_INFO_URL = "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s";
    private static final String OPEN_USER_INFO_URL = "http://127.0.0.1:8081/connect/userinfo?access_token=%s&openid=%s";

    public String getWxOAAppId() {
        return wxOAAppId;
    }

    public void setWxOAAppId(String wxOAAppId) {
        this.wxOAAppId = wxOAAppId;
    }

    public String getWxOAAppSecret() {
        return wxOAAppSecret;
    }

    public void setWxOAAppSecret(String wxOAAppSecret) {
        this.wxOAAppSecret = wxOAAppSecret;
    }

    public String getWxOpenAppId() {
        return wxOpenAppId;
    }

    public void setWxOpenAppId(String wxOpenAppId) {
        this.wxOpenAppId = wxOpenAppId;
    }

    public String getWxOpenSecret() {
        return wxOpenSecret;
    }

    public void setWxOpenSecret(String wxOpenSecret) {
        this.wxOpenSecret = wxOpenSecret;
    }

    public String getWxOpenRedirectUrl() {
        return wxOpenRedirectUrl;
    }

    public void setWxOpenRedirectUrl(String wxOpenRedirectUrl) {
        this.wxOpenRedirectUrl = wxOpenRedirectUrl;
    }

    public static String getOpenQrcodeUrl() {
        return OPEN_QRCODE_URL;
    }

    public static String getOpenAccessTokenUrl() {
        return OPEN_ACCESS_TOKEN_URL;
    }

    public static String getOpenUserInfoUrl() {
        return OPEN_USER_INFO_URL;
    }
}
